<template>
  <div class='home'>
    <div class="top">
      <div class="title">
        <img :src="require('@/assets/logo.png')">
        <span>家政大狮 & 线上综合服务平台</span>
      </div>
      <nav>
        <li v-for="(item, index) in items" :key="index" :class="{active:active==index}" @click="tabChange(index)">
          {{item}}</li>
      </nav>
    </div>
    <div class="banner">
      <img :src="require('@/assets/banner.png')">
    </div>
    <component :is="item" v-for="(item,index) in showCom" :key="index"></component>
    <footer>
      <h1 style="font-size:24px;">联系我们</h1>
      <div class="telme">联系电话：13392686032</div>
      <a class="copyright" href="https://beian.miit.gov.cn/" target="_blank">
        <span>©</span>
        <span>广州市千福企业有限公司</span>
        <span>粤ICP备2022015387号-1</span>
      </a>
    </footer>
  </div>
</template>

<script>
import About from "./About";
import Cultivate from "./Cultivate";
import Service from "./Service";
export default {
  data() {
    return {
      active: 0,
      items: ["首页", "家政培训", "家政服务", "关于我们"],
      comList: ["About", "Cultivate", "Service"],
      showCom: [],
    };
  },
  components: {
    About,
    Cultivate,
    Service,
  },
  created() {
    this.showCom = this.comList;
  },
  methods: {
    tabChange(index) {
      this.active = index;
      let tempArr = ["Cultivate", "Service", "About"];
      if (index == 0) {
        this.showCom = this.comList;
      } else {
        this.showCom = [];
        this.showCom.push(tempArr[index - 1]);
      }
    },
  },
};
</script>

<style scoped lang='less'>
.home {
  box-sizing: border-box;
  .banner {
    width: 1920px;
    height: 700px;
    margin: 0 auto;
    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }
  .top {
    position: sticky;
    top: 0;
    left: 0;
    display: flex;
    justify-content: space-between;
    width: 1920px;
    height: 90px;
    margin: 0 auto;
    font-size: 22px;
    padding: 16px 30px;
    background-color: #fff;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.06);
    box-sizing: border-box;
    .title {
      display: flex;
      align-items: center;
      width: 500px;
      img {
        width: 80px;
        height: 80px;
        margin-right: 6px;
        object-fit: cover;
      }
    }
    nav {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      width: 100%;
      li {
        display: flex;
        justify-content: center;
        align-items: center;
        min-width: 130px;
        color: #0c0b0a;
        text-align: center;
        padding: 12px 24px;
        margin-left: 10px;
        transition: all 0.5s;
        cursor: pointer;
      }
      .active {
        color: #fff;
        background-color: #1a87ec;
        border-radius: 50px;
      }
    }
  }

  footer {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 200px;
    font-size: 14px;
    padding-top: 103px;
    background-color: #fff;
    .telme {
      margin-top: 23px;
      font-size: 16px;
    }
    .copyright {
      display: flex;
      margin-top: 89px;
      text-decoration: none;
      cursor: pointer;
      color: black;
      &:hover {
        opacity: 0.5;
      }
      span {
        margin-left: 8px;
      }
    }
  }
}
</style>
